<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>平台统计</title>
    <link rel="stylesheet" type="text/css" href="../static/layui/css/layui.css">
    <script type="text/javascript" src="../static/js/jquery-3.3.1.min.js"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<h3><strong>平台统计</strong></h3>
<div class="demoTable" style="position: absolute;z-index: 1000 ;margin-top: 15px;">
    <form method="post">
    时间:
    <div class="layui-input-inline">
        <input type="text" class="layui-input" id="CreateTime" autocomplete="off" placeholder="开始时间" style="width: 150px">
    </div>
    至
    <div class="layui-input-inline">
        <input type="text" class="layui-input" id="FinishTime" autocomplete="off" placeholder="结束时间" style="width: 150px">
    </div>
    <div class="layui-input-inline">
        <select id="domoin" name="domoin" lay-verify="required" class="layui-input" style="width: 100px">
            <option value="">领域</option>
        </select>
    </div>
    <div class="layui-input-inline">
        <select id="circular" name="circular" lay-verify="required" class="layui-input" style="width: 100px">
            <option value="">政策</option>
        </select>
    </div>
    <div class="layui-input-inline">
        <select id="item" name="item" lay-verify="required" class="layui-input" style="width: 100px">
            <option value="">项目</option>
        </select>
    </div>
    <!--        <div class="layui-input-inline">-->
    <!--            <select id="fx" name="item" lay-verify="required" class="layui-input" style="width: 100px">-->
    <!--                <option value="">方向</option>-->
    <!--            </select>-->
    <!--        </div>-->
    <button class="layui-btn" data-type="reload" id="reload">查询</button>
    <div class="layui-input-inline">
        <input type="reset" class="layui-input"
               style="width: 60px;height: 38px;text-align: center;background-color:#16c4ff;color: white ">
    </div>
    </form>

</div>
<table class="layui-hide" id="test" lay-filter="test"></table>

<script src="../static/layui/layui.js"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->

<script>
    layui.use('table', function () {
        var table = layui.table;
        table.render({
            elem: '#test',
            url: '/selPlatform',
            title: '用户数据表',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['exports'],
            cols: [
                [{
                    field: 'platformDate',
                    title: '日期',
                    width: 130,
                    align: 'center'
                }, {
                    field: 'platformCount',
                    title: '补助公司数量',
                    width: 100,
                    align: 'center'
                }, {
                    field: 'platformSubsidy',
                    title: '补助公司金额',
                    width: 150,
                    align: 'center'
                }, {
                    field: 'platformNumber',
                    title: '补助个人数量',
                    width: 100,
                    align: 'center'
                }, {
                    field: 'platformSfp',
                    title: '补助个人金额',
                    width: 150,
                    align: 'center'
                }, {
                    field: 'domoinName',
                    title: '领域',
                    width: 172,
                    align: 'center'
                }, {
                    field: 'circularTitle',
                    title: '政策',
                    width: 172,
                    align: 'center'
                }, {
                    field: 'itemTitle',
                    title: '项目',
                    width: 172,
                    align: 'center'
                }, {
                    field: 'platformTotle',
                    title: '合计',
                    width: 145,
                    align: 'center'
                }]
            ],
            id: 'testReload',
            height: 200,
        });
        // 模糊查询 搜索
        var $ = layui.$, active = {
            reload: function () {
                var CreateTime = $('#CreateTime').val();
                var FinishTime = $('#FinishTime').val();
                var platformDomoinId = $('#domoin').val();
                var circular = $('#circular').val();
                var item = $('#item').val();
                // var fx = $('#fx').val();
                //执行重载
                table.reload('testReload', {
                    where: {
                        CreateTime: CreateTime,
                        FinishTime: FinishTime,
                        platformDomoinId: platformDomoinId,
                        platformCpId: circular,
                        platformItemId: item
                    }
                });
            }
        };
        //提交
        $('.demoTable .layui-btn').on('click', function (e) {
            //关闭from表单刷新功能
            e.preventDefault();
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
</script>
<script>
    layui.use('form', function () {
        var $ = layui.jquery;
        var form = layui.form;
        //领域
        $.ajax({
            url: '/selDomoin',
            dataType: 'json',
            type: 'post',
            success: function (data) {
                console.log(data);
                var item = data.data;
                var box = document.getElementById("domoin");
                for (var i = 0; i < item.length; i++) {
                    box.innerHTML += '<option value="' + item[i].domoinId + '">' + item[i].domoinName + '</option>';
                }
            }
        });
        //政策
        $.ajax({
            url: '/selCirculars',
            dataType: 'json',
            type: 'post',
            success: function (data) {
                console.log(data);
                var item = data.data;
                var box = document.getElementById("circular");
                for (var i = 0; i < item.length; i++) {
                    box.innerHTML += '<option value="' + item[i].circularId + '">' + item[i].circularTitle + '</option>';
                }
            }
        });
        //项目
        $.ajax({
            url: '/selItemAll',
            dataType: 'json',
            type: 'post',
            success: function (data) {
                console.log(data);
                var item = data.data;
                var box = document.getElementById("item");
                for (var i = 0; i < item.length; i++) {
                    box.innerHTML += '<option value="' + item[i].itemId + '">' + item[i].itemTitle + '</option>';
                }
            }
        });
    });
    //日期范围
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        //日期时间选择器
        laydate.render({
            elem: '#CreateTime'
            , type: 'date'
        });
        laydate.render({
            elem: '#FinishTime'
            , type: 'date'
        });
    });

</script>


<h3><strong>统计明细</strong></h3>
<table class="layui-hide" id="tests" lay-filter="tests"></table>

<script>
    layui.use('table', function () {
        var table = layui.table;
        table.render({
            elem: '#tests',
            url: '/selStatistical',
            title: '用户数据表',
            cols: [
                [{
                    field: 'statisticalId',
                    title: '序号',
                    hide: true
                }, {
                    field: 'statisticalDate',
                    title: '时间',
                    width: 130,
                    align: 'center'
                }, {
                    field: 'domoinName',
                    title: '领域',
                    width: 300,
                    align: 'center'
                }, {
                    field: 'circularTitle',
                    title: '政策',
                    width: 300,
                    align: 'center'
                }, {
                    field: 'itemTitle',
                    title: '项目',
                    width: 300,
                    align: 'center'
                }, {
                    field: 'statisticalApc',
                    title: '公司/个人',
                    width: 170,
                    align: 'center'
                }, {
                    field: 'statisticalMoney',
                    title: '金额',
                    width: 95,
                    align: 'center'
                }]
            ],
            page: true,
            height: 330,
        });
    });
</script>


</body>
</html>
